using UnityEngine;
using System.Collections;

public class Tocha : MonoBehaviour 
{
    private int id = 2;
    private Vector2 screen;
    private AudioClip click;

    void Start()
    {
        this.screen.y = GameObject.Find("Main Camera").GetComponent<Camera>().orthographicSize;
        this.screen.x = this.screen.y * GameObject.Find("Main Camera").GetComponent<Camera>().aspect;

        this.gameObject.AddComponent("MeshRenderer");
        this.gameObject.AddComponent("MeshFilter");

        Mesh mesh = Quad.Create(this.screen.x * 0.5f, this.screen.x * 0.5f);

        this.gameObject.GetComponent<MeshFilter>().mesh = mesh;
        this.gameObject.GetComponent<MeshRenderer>().material = AtlasGanhou.globalMaterial;

        this.transform.position = new Vector3(0, 0.5f, 0);
    }

    void Update()
    {
        this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		{
			new Vector2(AtlasGanhou.rects[id].xMin, AtlasGanhou.rects[id].yMax),
			new Vector2(AtlasGanhou.rects[id].xMax, AtlasGanhou.rects[id].yMax),
			new Vector2(AtlasGanhou.rects[id].xMax, AtlasGanhou.rects[id].yMin),
			new Vector2(AtlasGanhou.rects[id].xMin, AtlasGanhou.rects[id].yMin)
		};
    }
}
